﻿@using QDT.Core
@using QDT.Core.Members
@model QDT.Common.IPagedList<QDT.Core.OfflineInvest.OfflineContract>
@{
    Func<int, string> Status = x =>
        {
            switch (x)
            {
                case -2:
                    return "申请驳回";
                case -1:
                    return "待审核";
                case -11:
                    return "待结算审核";
                case 0:
                    return "审核通过";
                case 1:
                    return "提现待审核";
                case 2:
                    return "待转让";
                case 3:
                    return "转让中";
                case 4:
                    return "结束";
                default:
                    return "";
            }
        };
}

@section HeadSection {
    @Html.IncludeCSS("~/Content/Css/calendar.css")
    @Html.IncludeScript("~/Content/JS/calendar.js")
    <script type="text/javascript">

        function show_detail(contractId) {
            var url = '@Url.Action("ShowDetail", "Offline")' + '?id=' + contractId;
            showAjaxResult(url, "借款详细统计", 700, 400);
        }

        function tongyi_zongjian(userId) {
            if (confirm('确定要通过所选申请吗？')) {
                $.ajax({
                    url: '@Url.Action("LeaderAudit", "Offline")',
                    data: {
                        id: userId,
                        isAgree: true
                    },
                    dataType: 'json',
                    type: 'POST',
                    success: function (result) {
                        if (result.Status && result.Status == "true") {
                            alert(result.Message);
                            location.href = location.href;
                        } else {
                            alert(result.Message);
                        }
                    }
                });
            }
        }

        function bohui_zongjian(userId) {
            if (confirm('确定要驳回所选申请吗？')) {
                $.ajax({
                    url: '@Url.Action("LeaderAudit", "Offline")',
                    data: {
                        id: userId,
                        isAgree: false
                    },
                    dataType: 'json',
                    type: 'POST',
                    success: function (result) {
                        if (result.Status && result.Status == "true") {
                            alert(result.Message);
                            location.href = location.href;
                        } else {
                            alert(result.Message);
                        }
                    }
                });
            }
        }

    </script>
}

    <div class="main_title">
        线下投资记录</div>
    <div class="blank5">
    </div>
    <div class="search_row">
	    <form name="search" action="@Url.Action("BusinessFour")" method="get">	
            会员ID：<input type="text" class="textbox" name="userid"  size="8" value="@Request.Params["userid"]"/>
            会员名称：<input type="text" class="textbox" size="8" name="username" value="@Request.Params["username"]"/>
		    真名:<input type="text" class="textbox" size="8" name="realname" value="@Request.Params["realname"]" />
            分类:
	        <select name="status">
                <option value="999" selected="selected">所有状态</option>
                <option value="-1">待审核</option>
                <option value="-11">待结算审核</option>
                <option value="0">审核通过</option>
                <option value="1">提现待审核</option>
                <option value="2">待转让</option>
                <option value="3">转让中</option>
                <option value="4">结束</option>
                <option value="-2">申请驳回</option>
	        </select>
	        日期：<input type="text" class="textbox" id="createTime" name="createTime" value="@Request.Params["createTime"]" onfocus=" this.blur(); return showCalendar('createTime', '%Y-%m-%d', false, false, 'btn_CreateTime');" size="8"/>
            <input type="button" class="button" id="btn_CreateTime" value="选择时间" onclick=" return showCalendar('createTime', '%Y-%m-%d', false, false, 'btn_CreateTime'); " />

	        <input type="submit" class="button" value="搜索"/>
	    </form>
    </div>
    <div class="grid_box">
        <div class="grid_top">
        </div>
        @Html.Grid(Model).Columns(column =>
        {
            column.CheckBox(x => x.ID);
            column.For(x => x.ID).Named("编号").HeaderAttributes(style => "width:50px;align:center;");
            column.For(x => Html.ActionLink(x.UserName, "UserInfo", "Business", new { userid = x.UserId }, "")).Named("会员名称");
            column.For(x => x.RealName).Named("会员真名");
            column.For(x => x.StartDate.ToShortDateString()).Named("合同开始日期").SortColumnName("StartDate");
            column.For(x => x.InvestEndDate.ToShortDateString()).Named("投资结束时期").SortColumnName("InvestEndDate");
            column.For(x => x.Money).Named("合同金额").Format("{0:C2}");
            column.For(x => x.OverMoney).Named("投资余额").Format("{0:C2}");
            column.For(x => x.CurrentEarning.ToMoney()).Named("当期利息");
            column.For(x => x.RepayEarning.ToMoney()).Named("累计利息");
            column.For(x => Status(x.Status)).Named("状态");
            column.Buttons(btns => btns.Add(x => Html.ScriptLink("投标列表", "show_detail({0})", x.ID)));
            column.Buttons(btns => btns.Add(x => Html.ScriptLink(x.Status.Equals(-1) ? "通过审核" : "", "tongyi_zongjian({0})", x.ID))
                .Add(x => Html.ScriptLink(x.Status.Equals(-1) ? "驳回操作" : "", "bohui_zongjian({0})", x.ID))
                .Add(x => Html.ActionLink(x.Status.Equals(1) ? "同意提现" : " ", "ProcessContract", "Offline", new { id = x.ID, isAgree = true }, new { style = "color:red;" }))
                .Add(x => Html.ActionLink(x.Status.Equals(1) ? "拒绝提现" : " ", "ProcessContract", "Offline", new { id = x.ID, isAgree = false }, new {style="color:red;"})));
        }).Complex(ViewData)
        <div class="grid_foot">
        </div>
    </div>
    <div class="blank5">
    </div>
    @Html.Pager(Model)
